package com.pxxy.toturial.service.impl;

import com.pxxy.toturial.dao.ComputerDao;
import com.pxxy.toturial.dao.HostDao;
import com.pxxy.toturial.entity.Computer;
import com.pxxy.toturial.entity.Host;
import com.pxxy.toturial.service.ComputerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/******************
 * @Author yejf
 * @Description TODO
 */
@Component
public class ComputerServiceImpl implements ComputerService {

    //@Autowired
    @Resource
    private ComputerDao computerDao;

   /* @Autowired
    @Qualifier("hostDaoImpl")*/
   @Resource(name="hostDaoImpl2")
    private HostDao hostDao;

    @Override
    public int insert(Computer c) {
        System.out.println("委托 ComputerDao去完成");
        return computerDao.save(c);
    }

    @Override
    public Computer getById(Serializable id) {
        System.out.println("委托 ComputerDao 的findById方法去完成");
        return computerDao.findById(id);
    }

    @Override
    public List<Host> getAllHost() {
        System.out.println("委托 HostDao的 findAll方法去完成");
        return hostDao.findAll();
    }
}
